<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    // 目标对象
    const user = {
        name:'小米',
        age:19,
        wife:{
            name:'小明',
            age:20
        }
    }
    // 通过Proxy Reflact将目标对象变成代理对象
    const app = new Proxy(user,{
        get(target,prop){
            return Reflect.get(target,prop)
        },
        set(target,prop,value){
            return Reflect.set(target,prop,value)
        },
        deleteProperty(target,prop){
            return Reflect.deleteProperty(target,prop)
            console.log('delete方法调用');
        }
    })
    // 通过代理对象可以获取到目标对象的属性
    console.log(app.name);
    app.gender = '男';
    app.name = '小裴';

    delete app.name
    console.log(app);

</script>